package com.WaVel.service.impl;

import com.Emplyment.dto.QuestionBankDto;
import com.Emplyment.entity.QuestionBank;
import com.Emplyment.result.Result;
import com.Emplyment.vo.QuestionBankVo;
import com.WaVel.mapper.QuestionBankMapper;
import com.WaVel.service.InterviewQuestionsService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InterviewQuestionsServiceImpl implements InterviewQuestionsService {
    @Autowired
    private QuestionBankMapper questionBankMapper;

    @Override
    public List<QuestionBankVo> getQuestions() {
        List<QuestionBankVo> allQuestionBank = questionBankMapper.getAllQuestionBank();
        return allQuestionBank;
    }

    @Override
    public QuestionBank addQuestion(QuestionBankDto dto) {
        QuestionBank question = new QuestionBank();
        BeanUtils.copyProperties(dto, question);
        questionBankMapper.addQuestion(question);
        return question;
    }

    @Override
    public void deleteQuestion(Integer id) {
        questionBankMapper.deleteQuestion(id);
    }

    @Override
    public QuestionBank updateQuestion(QuestionBankDto dto) {
        QuestionBank question = new QuestionBank();
        BeanUtils.copyProperties(dto, question);
        questionBankMapper.updateQuestion(question);
        return question;
    }
}
